home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
cmouse.exe
/
CMOUSE.DOC
< prev
next >
Wrap
Text File
|
1991-07-27
|
8KB
|
215 lines
Cmouse.cpp for Borland C++
==========================
Thank you for downloading cmouse.zip. Compile cmoused.cpp,
cmouse.cpp and link with graphics.lib. Then run the demo
cmoused.exe. A mouse interrupt handler is provided and
should serve most all your needs.
The MicrosoftMouse class provides member functions for all
Microsoft Mouse Driver functions packaged in a convenient
interface. Do not instantiate any instances of the class -
instead access them through MM, the only instance of
MicrosoftMouse!
For example:
#include <stdio.h>
#include <cmouse.hpp>
main()
{
MM.open(); // initialize mouse
MM.show();
MM.autoEventUpdate();
while (!MM.leftPressed) do;
puts("Mouse's left button pressed.");
MM.close(); // clear mouse
return 0;
}
All cmouse coordinates are expressed in Borland C++'s
physical screen coordinates rather than the mouse's virtual
coordinates. Be sure to call MM.reset() after each video
mode change to enable this feature!
MM is a global instance of the MicrosoftMouse class. Since it
has no constructor or destructor, you must first call
MM.open() to prepare the mouse for use and MM.close() when
finished with the mouse. A constructor and destructor were
not used because the interrupt setting calls conflict with
C++ startup and exit code outside of main in some memory
models. Since MM is global, its constructor and destructor
would be called outside of main().
Look at the MicrosoftMouse class declaration in cmouse.hpp.
You will soon notice that the member functions don't
typically pass parameters but values are instead stored
directly in the MM instance's data fields. The reason I
don't pass parameters is so you don't have to provide
variables to store them in. Secondly, cmouse has a special
function called autoEventUpdate() that activates a prewritten
mouse event interrupt handler. All you do is call
MM.autoEventUpdate() and it updates the MM's data fields
whenever a mouse event happens as specified by MM.eventMask.
The mask is preconfigured to request an update whenever the
mouse moves, or a mouse button is pressed or released. That
way your application simply poles these fields for updates.
This should satisfy most of your requirements. If you need
something more sophisticated, you can use the code of
autoEventHandler() to cookbook your own interrupt handler!
For example:
MM.x = 10; MM.y = 20; MM.gotoxy();
// moves the mouse cursor to (10,20).
MM.updateStatusInfo()
if (MM.leftPressed)
// if left button pressed.
If you are wondering what the total effect of calling
MM.updateStatusInfo() is you can study the source. If you
want to do any serious mouse programming it would be a good
idea to pick up
"Microsoft Mouse Programmer's Reference."
Bellevue, Washington: Microsoft Press, 1989.
This is the main reference I used in coding cmouse. Rather
than repeat what is in this book or explain what the mouse
functions do, you should reference this book. By using the
book and reading the header of cmouse, you will soon get the
picture of what's going on.
Of course if you had activated the provided mouse interrupt
handler, all you would have to do to see if the left button
was pressed is test the field:
if (MM.leftPressed)
// if left button pressed.
To enable the mouse interrupt handler, you must call
MM.autoEventUpdate(). Check the demo code to see if you can
find this. Also study the display of the demo. It displays
many of the fields of MM. Use the mouse and see how these
fields register the changes. The function MouseReport() in
the demo produces this report. Look there to see how the
fields are accessed.
I have tested the omouse unit with Microsoft Mouse driver
version 7.00 and Microsoft's second generation serial mouse
as well as the ATI VGA Wonder Plus bus mouse. If the demo
won't run in graphics mode the most likey cause is your mouse
driver doesn't support the more advanced features of your
graphics card. I know, you have a paint program that works
fine with your mouse and driver so it must be cmouse. Well
many paint programs provide their own built-in drivers to
keep you from calling them with the same problem. Believe
me, call your mouse manufacturer and get the latest driver.
If you must call me, don't call in the middle of the night,
please!
Super VGA Modes
===============
At this time I am awaiting information from VESA for VESA
compliant SVGA modes. When I do I'll update cmouse for those
modes. In the mean time if you want to try it yourself you
must modify Xcell[], Ycell[], LeftTopOfs[], virtualX(),
virtualY(), physicalX(), and physicalY(). The standard modes
documented in the Microsoft Mouse Programmer's Reference are
for video modes 0-13 hex. This made it easy to implement
Xcell, Ycell, and LeftTopOfs in arrays. I'm thinking that I
will simply remap modes 23, 27, 33, 37, 54, 6A, 61, 62, 63,
65, and 67 hex into MM.vmode just above 13 hex so that these
arrays can simply be extended. I use these arrays to
automatically convert between physical screen coordinates and
mouse virtual coordinates.
Registration
============
If you find cmouse useful and are using it in your
applications, tell your friends. You don't need to register
cmouse -- it's freeware! All I ask is that you leave my
copyright notice intact!
Thanks again!
John W. Small
Voice: (703) 759-3838
CIS: 73757,2233
PSW / Power SoftWare
P.O. Box 10072
McLean, VA 22102 8072
(703) 759-3838
----------------end-of-author's-documentation---------------
Software Library Information:
This disk copy provided as a service of
Public (software) Library
We are not the authors of this program, nor are we associated
with the author in any way other than as a distributor of the
program in accordance with the author's terms of distribution.
Please direct shareware payments and specific questions about
this program to the author of the program, whose name appears
elsewhere in this documentation. If you have trouble getting
in touch with the author, we will do whatever we can to help
you with your questions. All programs have been tested and do
run. To report problems, please use the form that is in the
file PROBLEM.DOC on many of our disks or in other written for-
mat with screen printouts, if possible. PsL cannot debug pro-
programs over the telephone, though we can answer questions.
Disks in the PsL are updated monthly, so if you did not get
this disk directly from the PsL, you should be aware that the
files in this set may no longer be the current versions. Also,
if you got this disk from another vendor and are having prob-
lems, be aware that some files may have become corrupted or
lost by that vendor. Get a current, working disk from PsL.
For a copy of the latest monthly software library newsletter
and a list of the 3,000+ disks in the library, call or write
Public (software) Library
P.O.Box 35705 - F
Houston, TX 77235-5705
Orders only:
1-800-2424-PSL
MC/Visa/AmEx/Discover
Outside of U.S. or in Texas
o